/**
 * 
 */
package de.cbf.cam.dsa.tavern.carte.ui;

import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Iterator;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

import de.cbf.cam.dsa.tavern.carte.model.entities.Ingredient;
import de.cbf.cam.dsa.tavern.carte.model.entities.MealType;
import de.cbf.cam.dsa.tavern.carte.model.entities.helper.MinMax;
import de.cbf.cam.dsa.tavern.carte.model.entities.interfaces.IEditableEntity;

/**
 * @author Stefan Alter
 *
 */
public class CompositeEditMealType extends AbstractCompositeEditEntity {
	private CompositeEditMealTypeData compositeEditData;
	/**
	 * @param parent
	 * @param style
	 */
	public CompositeEditMealType(Composite parent, int style) {
		super(parent, style);		
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.interfaces.ICompositeEditEntity#clear()
	 */
	@Override
	public void clear() {
		compositeEditData.clearData();
	}
	@Override
	public void setEnabled(boolean enabled) {
		compositeEditData.setEnabled(enabled);
		super.setEnabled(enabled);
	}
	
	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.AbstractCompositeEditEntity#checkEntity(de.cbf.cam.dsa.tavern.carte.model.entities.interfaces.IEditableEntity)
	 */
	@Override
	protected boolean checkEntity(IEditableEntity value) {
		if (value instanceof MealType) {
			return true;			
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.AbstractCompositeEditEntity#setEntityData(de.cbf.cam.dsa.tavern.carte.model.entities.interfaces.IEditableEntity)
	 */
	@Override
	protected void setEntityData(IEditableEntity value) {
		compositeEditData.setEntityData(value);
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.AbstractCompositeEditEntity#createCompositeEntity(org.eclipse.swt.widgets.Composite)
	 */
	@Override
	protected Composite createCompositeEntity(Composite parent) {
		compositeEditData = new CompositeEditMealTypeData(parent, SWT.NONE); 
		return compositeEditData;
	}
	
//	=========================================
//		through to data composite
//	=========================================
	//Properties
	
	public void setIngredients(Iterator<Ingredient> iteratorIngredients) {
		compositeEditData.setIngredients(iteratorIngredients);		
	}
	public Ingredient getSelectedTreeIngredient(){
		return compositeEditData.getSelectedIngredient();
	}
	public String getSelectedIngredientName(){
		return compositeEditData.getSelectedIngredientName();
	}
	public void setTreeSelectedIngredient(Ingredient value){
		compositeEditData.setTreeSelectedIngredient(value);		
	}
	public void deSelectAllTreeIngredients(){
		compositeEditData.deSelectAllTreeIngredients();
	}
	public String getMealTypeName() {
		return compositeEditData.getMealTypeName();
	}
	public void setMealTypeName(String value) {
		compositeEditData.setMealTypeName(value);
	}
	
	public Double getPrice() {
		return compositeEditData.getPrice();
	}
	
	public void setPrice(Double value) {
		compositeEditData.setPrice(value);
	}	
	
	public Integer getSelectedMin(){
		return compositeEditData.getSelectedMin();
	}

	public Integer getSelectedMax(){
		return compositeEditData.getSelectedMax();
	}
	
	
	public void setSelectedItem(String value){
		compositeEditData.setSelectedItem(value);
	}
	public int getSelectedIndex(){
		return compositeEditData.getSelectedIndex();
	}
	public void setSelectedItem(int index){
		compositeEditData.setSelectedItem(index);
	}

	public HashMap<String, MinMax> getConfiguration(){
		return compositeEditData.getConfiguration();
	}


	public void setConfiguration(HashMap<String, MinMax> value){
		compositeEditData.setConfiguration(value);
	}

	//button en-/disabling ================================================

	public void setButtonAddEnabled(boolean value){
		compositeEditData.setButtonAddEnabled(value);
	}
	public void setButtonRemoveEnabled(boolean value){
		compositeEditData.setButtonRemoveEnabled(value);
	}


	public boolean registerNameModifyListener(ActionListener listener){
		return compositeEditData.registerNameModifyListener(listener);
	}
	public boolean deRegisterNameModifyListener(ActionListener listener){
		return compositeEditData.deRegisterNameModifyListener(listener);
	}
	
	
	public boolean registerPriceModifyListener(ActionListener listener){
		return compositeEditData.registerPriceModifyListener(listener);
	}
	public boolean deRegisterPriceModifyListener(ActionListener listener){
		return compositeEditData.deRegisterPriceModifyListener(listener);
	}
	public boolean registerIngredientSelectionListener(ActionListener listener){
		return compositeEditData.registerIngredientSelectionListener(listener);
	}
	public boolean deRegisterIngredientSelectionListener(ActionListener listener){
		return compositeEditData.deRegisterIngredientSelectionListener(listener);
	}
	public boolean registerConfigurationSelectionListener(ActionListener listener){
		return compositeEditData.registerConfigurationSelectionListener(listener);
	}
	public boolean deRegisterConfigurationSelectionListener(ActionListener listener){
		return compositeEditData.deRegisterConfigurationSelectionListener(listener);
	}
	
	public boolean registerAddIngredientListener(ActionListener listener){
		return compositeEditData.registerAddIngredientListener(listener);
	}
	public boolean deRegisterAddIngredientListener(ActionListener listener){
		return compositeEditData.deRegisterAddIngredientListener(listener);
	}
	
	public boolean registerRemoveIngredientListener(ActionListener listener){
		return compositeEditData.registerRemoveIngredientListener(listener);
	}
	public boolean deRegisterRemoveIngredientListener(ActionListener listener){
		return compositeEditData.deRegisterRemoveIngredientListener(listener);
	}
	public boolean registerModifyConfigurationListener(ActionListener listener){
		return compositeEditData.registerModifyConfigurationListener(listener); 
	}
	public boolean deRegisterModifyConfigurationListener(ActionListener listener){
		return compositeEditData.deRegisterModifyConfigurationListener(listener);
	}
	
	public boolean registerConfigurationElementSelectionListener(ActionListener listener){
		return compositeEditData.registerConfigurationElementSelectionListener(listener);
	}
	public boolean deRegisterConfigurationElementSelectionListener(ActionListener listener){
		return compositeEditData.deRegisterConfigurationElementSelectionListener(listener);
	}
		
		

}
